package ru.study.thinkin.chapter10.gui;

import java.util.*;

public  class  Controller {
	public long con_id = new Random().nextInt(200);
	private LinkedList<Event> eventList = new LinkedList<Event>();
	
	public  void addEvent(Event c) {
		eventList.add(c);
	}
	
	public  void addEventFirst(Event c) {
		eventList.addFirst(c);		
	}
	public void run() {
		while(eventList.size()>0) {			
			for(Event e :  new ArrayList<Event>(eventList)) {			  
				if (e.ready()) {
					System.out.println(e);
					e.action();
					eventList.remove(e);					
				}
				break;
			}	
		}
		
	}
	
}
